//
//  StratrgyNearbyCollectionViewCell.m
//  ITrip
//
//  Created by dllo on 15/5/25.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "StratrgyNearbyCollectionViewCell.h"
#import <UIImageView+AFNetworking.h>
@implementation StratrgyNearbyCollectionViewCell

- (void)dealloc
{
    [self.nameNearbyLabel release];
    [self.distanceLabel release];
    [self.distanceView release];
    [self.imageview release];
    [super dealloc];
}

- (void)setStrategyNearbyModel:(StrategyNearbyModel *)strategyNearbyModel
{
    self.nameNearbyLabel.text = strategyNearbyModel.nameNearby;
    NSString *str = @"km";
    self.distanceLabel.text = [str stringByAppendingFormat:@"%ld",strategyNearbyModel.distanceNearby];
    [self.imageview setImageWithURL:[NSURL URLWithString:strategyNearbyModel.image_url_Nearby] placeholderImage:nil];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createMyView];
    }
    return self;
}

- (void)createMyView
{
    self.imageview = [[UIImageView alloc]init];
    [self.contentView addSubview:self.imageview];
    
    self.nameNearbyLabel = [[UILabel alloc]init];
    [self.imageview addSubview:self.nameNearbyLabel];
    
    
    self.distanceView = [[UIView alloc]init];
    [self.imageview addSubview:self.distanceView];
    
    self.distanceLabel = [[UILabel alloc]init];
    [self.imageview addSubview:self.distanceLabel];
    
    [self.nameNearbyLabel release];
    [self.distanceLabel release];
    [self.imageview release];
    [self.distanceView release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.nameNearbyLabel.frame = CGRectMake(0, 120, self.contentView.frame.size.width, self.contentView.frame.size.height - 120);
    self.nameNearbyLabel.backgroundColor = [UIColor whiteColor];
    self.nameNearbyLabel.textAlignment = NSTextAlignmentCenter;
    self.nameNearbyLabel.font = [UIFont systemFontOfSize:18];
    
    
    self.distanceView.frame = CGRectMake(0, 100, self.contentView.frame.size.width, self.contentView.frame.size.height - 140);
    self.distanceView.backgroundColor = [UIColor blackColor];
    self.distanceView.alpha = 0.4;
    
    self.distanceLabel.frame = CGRectMake(0, 100, self.contentView.frame.size.width, self.contentView.frame.size.height - 140);
//    self.distanceLabel.backgroundColor = [UIColor clearColor];
    self.distanceLabel.textAlignment = NSTextAlignmentCenter;
    self.distanceLabel.textColor = [UIColor whiteColor];
    
    self.imageview.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 40);
    self.imageview.backgroundColor = [UIColor colorWithRed:227/255.0 green:233/255.0 blue:240/255.0 alpha:1];
    
    
}



@end
